package de.wittekind.bundesjugendspiele.server.calc;

import java.util.HashMap;
import java.util.Map;

import de.wittekind.bundesjugendspiele.server.interfaces.Discipline;
import de.wittekind.bundesjugendspiele.server.interfaces.Schueler.Gender;

public class Formula {

	public static int A=1;
	public static int C=2;
	public static int D=3;
	private static Map<Gender,Map<Discipline,Map<Integer,Double>>> map=null;
	
	private static void init()
	{
		map=new HashMap<Gender,Map<Discipline,Map<Integer,Double>>>();
		
		Map<Discipline,Map<Integer,Double>> maleMap=new HashMap<Discipline,Map<Integer,Double>>();
		Map<Discipline,Map<Integer,Double>> femaleMap=new HashMap<Discipline,Map<Integer,Double>>();
		

		maleMap.put(Discipline.SPRINT50, getMap(3.79000,0.00690,50));
		maleMap.put(Discipline.SPRINT75, getMap(4.10000,0.00664,75));
		maleMap.put(Discipline.SPRINT100, getMap(4.34100,0.00676,100));
		maleMap.put(Discipline.AUSDAUER1000, getMap(2.15800,0.00600,1000));
		maleMap.put(Discipline.AUSDAUER2000, getMap(1.78400,0.00600,2000));
		maleMap.put(Discipline.AUSDAUER3000, getMap(1.70000,0.00580,3000));
		maleMap.put(Discipline.HOCHSPRUNG, getMap(0.84100,0.00080));
		maleMap.put(Discipline.WEITSPRUNG, getMap(1.15028,0.00219));
		Map<Integer, Double> stossMale = getMap(1.42500,0.00370);
		maleMap.put(Discipline.STOSS, stossMale);
		maleMap.put(Discipline.STOSS3000, stossMale);
		maleMap.put(Discipline.STOSS4000, stossMale);
		maleMap.put(Discipline.STOSS5000, stossMale);
		maleMap.put(Discipline.STOSS6250, stossMale);
		maleMap.put(Discipline.SCHLEUDERBALL, getMap(1.59500,0.009125));
		maleMap.put(Discipline.WURF200, getMap(1.93600,0.01240));
		maleMap.put(Discipline.WURF80, getMap(2.80000,0.01100));
		
		femaleMap.put(Discipline.SPRINT50, getMap(3.64800,0.00660,50));
		femaleMap.put(Discipline.SPRINT75, getMap(3.99800,0.00660,75));
		femaleMap.put(Discipline.SPRINT100, getMap(4.00620,0.00656,100));
		femaleMap.put(Discipline.AUSDAUER800, getMap(2.02320,0.00647,1000));
		femaleMap.put(Discipline.AUSDAUER2000, getMap(1.80000,0.00540,2000));
		femaleMap.put(Discipline.AUSDAUER3000, getMap(1.75000,0.00500,3000));
		femaleMap.put(Discipline.HOCHSPRUNG, getMap(0.88070,0.00068));
		femaleMap.put(Discipline.WEITSPRUNG, getMap(1.09350,0.00208));
		Map<Integer, Double> stossFemale = getMap(1.27900,0.00398);
		femaleMap.put(Discipline.STOSS, stossFemale);
		femaleMap.put(Discipline.STOSS3000, stossFemale);
		femaleMap.put(Discipline.STOSS4000, stossFemale);
		femaleMap.put(Discipline.STOSS5000, stossFemale);
		femaleMap.put(Discipline.STOSS6250, stossFemale);
		femaleMap.put(Discipline.SCHLEUDERBALL, getMap(1.08500,0.00921));
		femaleMap.put(Discipline.WURF200, getMap(1.41490,0.01039));
		femaleMap.put(Discipline.WURF80, getMap(2.02320,0.00874));
		
		
		map.put(Gender.MALE, maleMap);
		map.put(Gender.FEMALE,femaleMap);
		
	}
	
	private static Map<Integer,Double> getMap(double a,double c)
	{
		Map<Integer,Double> map=new HashMap<Integer,Double>();
		map.put(A, a);
		map.put(C, c);
		map.put(D, 0D);
		return map;
	}
	
	private static Map<Integer,Double> getMap(double a,double c, double distance)
	{
		Map<Integer,Double> map=new HashMap<Integer,Double>();
		map.put(A, a);
		map.put(C, c);
		map.put(D, distance);
		return map;
	}
	
	public static Map<Integer,Double> get(Gender gen,Discipline dis)
	{
		if(map==null)
		{
			init();
		}
		return map.get(gen).get(dis);
	}
	

	public static void main(String[] argv) {
		for ( Discipline d : Discipline.values() ) {
			System.out.println(d);
			System.out.println(get(Gender.MALE, d));
			System.out.println(get(Gender.FEMALE, d));
		}
	}	

}
